package recursion;

import tools.Times;

import java.util.Stack;

/**
 * @Author: LDeng
 * @Date: 2021-04-12 14:25
 */
public class Main {

    public static void main(String[] args) {
        Fib fib = new Fib();
        ClimbStairs climbStairs = new ClimbStairs();
        Hanoi hanoi = new Hanoi();
        Times.test("fib0", () -> {
            System.out.println(fib.fib0(10));
        });

        Times.test("fib1", () -> {
            System.out.println(fib.fib1(40));
        });

        Times.test("fib2", () -> {
            System.out.println(fib.fib2(40));
        });

        Times.test("fib3", () -> {
            System.out.println(fib.fib3(40));
        });

        Times.test("fib5", () -> {
            System.out.println(fib.fib5(40));
        });

        Times.test("fib6", () -> {
            System.out.println(fib.fib6(40));
        });

        Times.test("climbStair", () -> {
            System.out.println(climbStairs.climbStairs(5));
        });

        Times.test("Hanoi", () -> {
            hanoi.hanoi(3, "A", "B", "C");
        });
        //log(20000);
        System.out.println("-------------------");
        log2(20000);
    }

    static void log(int n) {
        if (n < 1) return;
        log(n - 1);
        int v = n + 10;
        System.out.println(v);
    }


    static class Frame {
        int n;
        int v;

        Frame(int n, int v) {
            this.n = n;
            this.v = v;
        }
    }

    static void log2(int n) {
        Stack<Frame> frames = new Stack<Frame>();
        while (n > 0) {
            frames.push(new Frame(n, n + 10));
            n--;
        }
        while (!frames.isEmpty()) {
            Frame frame = frames.pop();
            System.out.println(frame.v);
        }
    }

}
